/* SPDX-License-Identifier: GPL-2.0 */
/*
 * lombo_gpadc.h - head file for lombo gpadc dirver
 *
 * Copyright (C) 2016-2018, LomboTech Co.Ltd.
 * Author: lomboswer <lomboswer@lombotech.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <mach/common.h>

#if defined(CONFIG_ARCH_LOMBO_N7V1)
#include "./csp/n7v1/csp_gpadc.h"
#elif defined(CONFIG_ARCH_LOMBO_N7V3)
#include "./csp/n7v3/csp_gpadc.h"
#elif defined(CONFIG_ARCH_LOMBO_N7V5) || defined(CONFIG_ARCH_LOMBO_N5V1)
#include "./csp/n7v5/csp_gpadc.h"
#elif defined(CONFIG_ARCH_LOMBO_N9V1) || defined(CONFIG_ARCH_LOMBO_N9V3)
#include "./csp/n9v1/csp_gpadc.h"
#else
#error platform invalid
#endif

#define DRIVER_NAME		"lombo-gpadc"
#define PARENT_NULL_CLK		"null_clk"
#ifdef CONFIG_ARCH_LOMBO_N9V1
#define PARENT_CLK		"a_hf_clk"
#else
#define PARENT_CLK		"osc24m"
#endif

#define VOL_TO_REG(vol, vol_max) (((vol * 1000) / vol_max * 0xfff) / 1000)
/* max number of gpadc channel */
#define CHANNEL_MAX_NUM	8

struct key_threshold {
	u32 low_thre;
	u32 high_thre;
};

struct io_channel {
	int chan_num;
	int channel[CHANNEL_MAX_NUM];
};

struct ctl_channel {
	int ctl_num;
	int channel[CHANNEL_MAX_NUM];
};

struct lombo_gpadc_dev {
	void __iomem		*base;
	struct clk		*gpadc_clk;
	struct clk		*clk_gate;
	struct clk		*clk_reset;
	struct clk		*parent_clk;
	int			irq;
	struct input_dev	*key_dev;
	struct key_threshold	key_thre[10];
	int			vol_thre;
	int			key_num;
	struct io_channel	io_channel;
	struct ctl_channel	ctl_channel;
};

